欢迎使用CSDN-markdown编辑器
来源:互联网 发布:苹果cms监控软件手机版 编辑:程序博客网 时间:2024/06/07 19:54
Hey, I’m your first snippet!
Hey, I’m your first snippet!
Now Paste will keep everything you copy to allow you use your clipboard history whenever you need it!
Feel free to just delete me or pin me to a new Pinboard and I will always be with you :)
OK,anywhere I must write something for the beginning
Mental Mutual Masturbation,翻译成中文叫「精神互撸」。说的是一帮人说着一些他们自己也似懂非懂的概念,讨论一些他们自己也似懂非懂的东西,越说越嗨,共同营造智力上升的快感。
When should i use ?
When should i use str() and when should i use repr() ?
Almost always use str when creating output for end users.
repr is mainly useful for debugging and exploring. For example, if you suspect a string has non printing characters in it, or a float has a small rounding error, repr will show you; str may not.
repr can also be useful for for generating literals to paste into your source code. It can also be used for persistence (with ast.literal_eval or eval), but this is rarely a good idea–if you want editable persisted values, something like JSON or YAML is much better, and if you don’t plan to edit them, use pickle.
2.In which cases i can use either of them ?
Well, you can use them almost anywhere. You shouldn’t generally use them except as described above.
3.What can str() do which repr() can’t ?
Give you output fit for end-user consumption–not always (e.g., str([‘spam’, ‘eggs’]) isn’t likely to be anything you want to put in a GUI), but more often than repr.
4.What can repr() do which str() can’t
Give you output that’s useful for debugging–again, not always (the default for instances of user-created classes is rarely helpful), but whenever possible.
And sometimes give you output that’s a valid Python literal or other expression–but you rarely want to rely on that except for interactive exploration.
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- php中正则表达式
- SPOJ Count on a tree(树上第K大)
- FIDO UAF Extension
- Android 之 阿里百川 -- 云消息推送服务
- 【poj3070】 Fibonacci 【矩阵乘法】
- 欢迎使用CSDN-markdown编辑器
- [FAQ19857]采用Signature Scheme v2签名方式的APK预置进系统失败
- js键盘事件全面控制详解
- 将图片数据转化为LMDB数据
- 队列
- POJ1182 食物链(并查集)
- 接口的多继承和实现
- MDO3054示波器的使用
- Eclipse中用git解决冲突----避免每次重新拉代码