Python 学习笔记(一)

最近在学习Python,为了督促自己,特此在CSDN上记录学习过程。本人初级程序员,觉得Python入门简单一些,平时业余时间学习一下,由浅入深,希望看到的人不要笑我。

谢谢大家,希望大家也来监督我哟。

Python 版本 3.5.1

最先说的还是 input( ) 了。

 Python 2.7的 raw_input( ) 已经 替换成了 input( )

raw_input

Converts raw_input() to input().

input ( [ prompt ] )

If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read,EOFError is raised. Example:

>>> s = input('--> ')  
--> Monty Python's Flying Circus
>>> s  
"Monty Python's Flying Circus"

If the readline module was loaded, theninput() will use it to provide elaborate line editing and history features.

本来还有些纠结,看来不能用raw_iput( ) 了。

简单练习1.

输入一个数字,并打印出来

#!/usr/bin/env python
a = input()
b = input()
a = int(a)
b = int(b)
print("a = %d"%a)
c = a % b
d = a  ** b
print("c = %d"%c)
print(a)
输出结果:

4
5
a = 4
c = 4
4

简单练习2.

输入一个字符串,用for 打印出单个字符。

a = input("input a string")
for i in a:
    print(i)
输出结果:

input a stringpython
p
y
t
h
o
n




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值