变量和简单数据类型

一、字符串变量

1. .py指一个python程序

2.变量 命名:变量名常用规则、慎用易混字母 使用小写Python变量名

3.字符串 可以用单引号也可以用双引号 一些方法:

    1.title()首字母大写

    2.upper()方法所有字母大写

    3.lower()方法所有首字母变小写

4.合并拼接字符串 使用“+”号进行拼接

5.使用制表符"\t"与换行符"\n"添加空白

6.删除空白

    (1)rstrip()方法 找出字符串开头与结尾多余的空白

    (2)lstrip()方法 剔除开头字符串

    (3)strip()方法 剔除末尾字符串

7.使用字符串时需要避免一些语法错误,主要是双引号单引号的混用问题。

二、数字

1.运算 “+” “-” “*” “/” **表示乘方

2.浮点数 python自动处理

    运算0.1+0.2的时候不一定等于0.3 因为计算机的计算都是先将十进制转化二进制 再转化为十进制 而这样的数字不是每一个都有与之对应的,所以很可能出现一些想不到的答案 计算机本身存在的问题 一般存在10**-15次方左右

3.使用str()函数,避免类型错误。

函数与方法的区别,方法是相对于对象而言,函数是相对于变量而言的。(不是错误,就想画上一条线)

4.注释:#单行注释 以及‘'' ''' 写好注释非常的重要,看过好一点的每个类与函数下方一行都会介绍主要的功能,所以需要好好的学习写注释啊,避免重复的花时间去看代码。

5.python之禅 The zen of python

打开python直接输入import this 就会出现这样的一首小诗 还是很浪漫的程序猿嘛

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea -- let's do more of those!


或许这就是python程序员的浪漫吧,不过我好像只是简单的看到了 简单的比复杂的好 确实这样呀。

以后别人问我为什么用python呢?

我就说因为这个简单啊  ouo  好像是这个道理

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值