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]);
                }
            }

  • 相关阅读:
    HDU 4825 字典树
    HDU4287 字典树
    HDU 3973 AC's String 字符串哈希
    HDU5296 Annoying problem(LCA)
    Gym 100712L Alternating Strings II(单调队列)
    数据结构专题
    HDU5033 Building(单调栈)
    HDU2888 Check Corners(二维RMQ)
    HDU 4123 Bob’s Race(RMQ)
    HDU3530 Subsequence(单调队列)
  • 原文地址:https://www.cnblogs.com/chenli0513/p/1869030.html
Copyright © 2011-2022 走看看