Giter Site home page Giter Site logo

pythonguide's Introduction

PythonGuide

This`s a guide of python. 中文说明

import json
data = {'b':123,'c':456,'a':'789'}

d1 = json.dumps(data,sort_keys=True,indent=4);

print d1
print data


print '''line1
line2
line3'''

print 3>2

print True and False

print not True

age = 17
if age >18:
    print 'adult'
else:
    print 'teenager'
PI=1111
print PI
print 10.0/3
#list
classmates=['Mark','Bob','Tracy']
print classmates

# list len
print len(classmates)
print classmates[0]

# last
print classmates[-1]
classmates.append("Adam")
print classmates
classmates.insert(1,'aaaa')
print classmates
classmates.pop();
print classmates

#tuple Not Change.diff list:not append insert
noChange=('aa','bb')
print noChange

t = (1,)
print t

L = [
    ['Apple', 'Google', 'Microsoft'],
    ['Java', 'Python', 'Ruby', 'PHP'],
    ['Adam', 'Bart', 'Lisa']
]
print L[0][0]
print L[1][1]
print L[2][2]

#if...elif
age = 3
if age >= 18:
    print('adult')
elif age >= 6:
    print('teenager')
else:
    print('kid')
s = '123'
birth = int(s)
if birth<200:
    print 'AAA'
else:
    print 'BBB'

#for in
names=['Mark','Bob','Tracy']
for name in names:
    print name

# 1+2....+1000 range
sum=0
for x in range(1000):
    sum = sum + x
print sum

n = 0
while n < len(L):
    i = 0
    while i < len(L[n]):
        print L[n][i]
        i = 1+i
    n = 1+n
#dict->Map
d = {'Mark':95,'Bob':75,'Tracy':85}
print d['Mark']
d.pop('Tracy')
print d

http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014319106919344c4ef8b1e04c48778bb45796e0335839000

pythonguide's People

Contributors

xiyoumc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.