栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python day1

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python day1

print(‘hello word’)
hello word

内置对象类型:
整数(int)、浮点数(float),字符串(str),列表、元组、字典、集合
不能单独定义变量

round(0.123456,5)
0.12346
import math
print(“hellow word”)
import sys
b=sys.getdefaultencoding()
print(b)
print(“hellow word”)
a=“python”
type(a)
print(type(a))
m=“python”
n=“book”
print(m+n)
print(m3)
print(len(m
3),‘p’ in m)
r=“python book”
print(r[-1],r[1: 9],“切片”,)
print(r[:9:2])
name=input("your name: ")
age=input("your age: ")
after=int(age)+10
print(“your name is :”,name)
print(“after ten years, you are”,after)

s=“python”
s
‘python’
s.index(‘n’)
5
s="python lesson’
File “”, line 1
s=“python lesson’
^
SyntaxError: EOL while scanning string literal
s=“python lesson”
s.index(‘n’,6)
12
s.index(‘on’)
4
a=“I LOVE PYTHON”
a.split(” “)
[‘I’, ‘LOVE’, ‘PYTHON’]
lst=a.split(” ")
lst
[‘I’, ‘LOVE’, ‘PYTHON’]
“-”.join(lst)
‘I-LOVE-PYTHON’
"I like {0} and {1}"format(“python”,“book”)
File “”, line 1
"I like {0} and {1}"format(“python”,“book”)
^
SyntaxError: invalid syntax
“I like {0} and {1}”.format(“python”,“book”)
‘I like python and book’
“I like {0:10} and {1:>15}”.format(“python”,“book”)
‘I like python and book’
“I like {0:^10} and {1:>15}”.format(“python”,“book”)
‘I like python and book’
“she is {0:4d} years old and {1:.1f}m in height”.format(28,1.68)
‘she is 28 years old and 1.7m in height’

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1012247.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号