zoukankan      html  css  js  c++  java
  • 浅尝python语法,挺有意思的与c#语法做了对比 原创 create by lee

      浅尝python语法,挺有意思的。

    ////////////////////////////////////////////////////////////////
    >>> # Measure some strings:
    ... a = ['cat', 'window', 'defenestrate']
    >>> for x in a:
    ...     print(x, len(x))
    ...
    cat 3
    window 6
    defenestrate 12

    ////////////////////////////////////////////////////////////////

    >>> for x in a[:]: # make a slice copy of the entire list
    ...    if len(x) > 6: a.insert(0, x)
    ...
    >>> a
    ['defenestrate', 'cat', 'window', 'defenestrate']

    >>> for i in range(5):
    ...     print(i)
    ...
    0
    1
    2
    3
    4

    代码
    ////////////////////////////////////////////////////////////////
    >>> a = ['Mary''had''a''little''lamb']
    >>> for i in range(len(a)):
    ...     
    print(i, a[i])
    ...
    0 Mary
    1 had
    2 a
    3 little
    4 lamb

     //与c#做对照 
      

    代码
    static void Main(string[] args)
            {
                
    string[] strArrary = { "a","b","c","d","e","f"};
                
    for (int i = 0; i < strArrary.Length; i++)
                {
                    Console.WriteLine(
    "{0},{1}",i,strArrary[i]);
                }
            }

  • 相关阅读:
    ti8168 eth0 启动
    MVC 5 Ajax + bootstrap+ handle bar 例: 实现service 状态
    MinGW 介绍
    VC POST表单——登录验证新浪邮箱
    关于ActionContext.getContext()的使用方法心得
    java对象数组
    播放音乐案例
    service
    监听短信(监听系统广播)
    普通广播接收者和有序广播接收者
  • 原文地址:https://www.cnblogs.com/chenli0513/p/1869030.html
Copyright © 2011-2022 走看看