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’

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值