jython语言学习笔记
1.变量可以随便定义,不限制类型,不限制数值。开头空4个空格,使用def定义函数,可以嵌套,可以传参。
2.每个语句结束的时候没有分号。定义类的时候没有括号。在print语句的后面有格式转换时要加上% , for和while之后要加冒号,快捷键被我改成了CTRL+R 和D
| Method | Description of Functionality |
| capitalize() | Returns a capitalized copy of string |
| center (width[,fill]) | Returns a repositioned string with specified width and provide optional padding filler character |
| count(sub[,start[,end]]) | Count the number of distinct times the substring occurs within the string |
| decode([encoding[,errors]]) | Decodes and returns Unicode string |
| encode([encoding[,errors]]) | Returns an encoded version of a string |
| endswith(suffix[,start[,end]]) | Returns a boolean to state whether the string ends in a given pattern |
| expandtabs([tabsize]) | Converts tabs within a string into spaces |
| find(sub[,start[,end]]) | Returns the index of the position where the first occurrence of the given substring begins |
| index(sub[,start[,end]) | Returns the index of the position where the first occurrence of the given substring begins. Raises a ValueError with the substring is not found. |
| isalnum() | Returns a boolean to state whether the string contain only alphabetic and numeric characters |
| isalpha() | Returns a boolean to state whether the string contains all alphabetic characters |
| isdigit() | Returns a boolean to state whether the string contains all numeric characters |
| islower() | Returns a boolean to state whether a string contains all lowercase characters |
| isspace() | Returns a boolean to state whether the string consists of all whitespace |
| istitle() | Returns a boolean to state whether the first character of each word in the string is capitalized |
| isupper() | Returns a boolean to state whether all characters within the string are uppercase |
| join(sequence) | Returns a copy of sequence joined together with the original string placed between each element |
| ljust(width[,fillchar]) | Returns a string of the specified width along with a copy of the original string at the leftmost bit. (Optionally padding empty space with fillchar) |
| lower() | Returns a copy of the original string with all characters in the string converted to lowercase |
| lstrip([chars]) | Removes the first found characters in the string from the left that match the given characters. Also removes whitespace from the left. Whitespace removal is default when specified with no arguments. |
| partition(separator) | Returns a partitioned string starting from the left using the provided separator |
| replace(old,new[,count]) | Returns a copy of the original string replacing the portion of string given in old with the portion given in new |
| rfind(sub[,start[,end]]) | Searches string from right to left and finds the first occurrence of the given string and returns highest index where sub is found |
| rindex(sub[,start[,end]]) | Searches string from right to left and finds the first occurrence of the given string and either returns highest index where sub is found or raises an exception |
| rjust(width[,fillchar]) | Returns copy of string Aligned to the right by width |
| rpartition(separator) | Returns a copy of stringPartitioned starting from the right using the provided separator object |
| rsplit([separator[,maxsplit]]) | Returns list of words in string and splits the string from the right side and uses the given separator as a delimiter. If maxsplit is specified then at most maxsplit splits are done (from the right). |
| rstrip([chars]) | Returns copy of string removing the first found characters in the string from the right that match those given. Also removes whitespace from the right when no argument is specified. |
| split([separator[,maxsplit]]) | Returns a list of words in string and splits the string from the left side and uses the given separator as a delimiter. |
| splitlines([keepends]) | Splits the string into a list of lines. Keepends denotes if newline delimiters are removed. Returns the list of lines in the string. |
| startswith(prefix[,start[,end]]) | Returns a boolean to state whether the string starts with the given prefix |
| strip([chars]) | Returns a copy of string with the given characters removed from the string. If no argument is specified then whitespace is removed. |
| swapcase() | Returns a copy of the string the case of each character in the string converted. |
| title() | Returns a copy of the string with the first character in each word uppercase. |
| translate(table[,deletechars]) | Returns a copy of the string using the given character translation table to translate the string. All characters occurring in optional deletechars argument are removed. |
| upper() | Returns a copy of string with all of the characters in the string converted to uppercase |
| zfill(width) | Returns a numeric string padded from the left with zeros for the specified width. |
| d | signed integer decimal |
| i | signed integer |
| o | unsigned octal |
| u | unsigned decimal |
| x | unsigned hexidecimal (lowercase) |
| X | unsigned hexidecimal (uppercase letters) |
| E | floating point exponential format (uppercase ‘E’) |
| e | floating point exponential format (lowercase ‘e’) |
| f | floating point decimal format (lowercase) |
| F | floating point decimal format (same as ‘f’) |
| g | floating point exponential format if exponent < -4, otherwise float |
| G | floating point exponential format (uppercase) if exponent < -4, otherwise float |
| c | single character |
| r | string (converts any python object using repr()) |
| s | string (converts any python object using str()) |
| % | no conversion, results in a percent (%) character if specified twice |
3. jython中的string和java一样也是不可变的。
4. 一个滑片list是包含开始数字,不包含结束数字的。pop()的同时会remove. remove()操作只能删除第一个匹配的。
| index | Returns the index of the first value in the list which matches a given value. |
| count | Returns the number of items in the list which equal a given value. |
| sort | Sorts the items contained within the list and returns the list |
| reverse | Reverses the order of the items contained within the list, and returns the list |
5.数组与List的区别是,List是可以改变的,而数组是不可以改变的。
| Method or Function | Description |
| len(dictionary) | Function that returns number of items within the given dictionary. |
| dictionary [key] | Returns the item from the dictionary that is associated with the given key. |
| dictionary[key] = value | Sets the associated item in the dictionary to the given value. |
| del dictionary[key] | Deletes the given key/value pair from the dictionary. |
| dictionary.clear() | Method that removes all items from the dictionary. |
| dictionary.copy() | Method that creates a shallow copy of the dictionary. |
| has_key(key) | Function that returns a boolean stating whether the dictionary contains the given key. (Deprecated in favor of using in’) |
| key in d | Returns a boolean stating whether the given key is found in the dictionary |
| key not in d | Returns a boolean stating whether the given key is not found in the dictionary |
| items() | Returns a list of tuples including a copy of the key/value pairs within the dictionary. |
| keys() | Returns the a list of keys within the dictionary. |
| update([dictionary2]) | Updates dictionary with the key/value pairs from the given dictionary. Existing keys will be overwritten. |
| fromkeys(sequence[,value]) | Creates a new dictionary with keys from the given sequence. The values will be set to the value given. |
| values() | Returns the values within the dictionary as a list. |
| get(key[, b]) | Returns the value associated with the given key. If the key does not exist, then returns b. |
| setdefault(key[, b]) | Returns the value associated with the given key. If the key does not exist, then the key value is set to b (mydict[key] = b) |
| pop(key[, b]) | Returns and removes the key/value pair associated with the given key. If the key does not exist then returns b. |
| popItem() | An arbitrary key/value pair is popped from the dictionary |
| iteritems() | Returns an iterator over the key/value pairs in the dictionary. |
| iterkeys() | Returns an iterator over the keys in the dictionary. |
| itervalues() | Returns an iterator over the values in the dictionary. |
6. sets是无序的,而且也不能重复,dic是可以重复的,sets使用前必须要加入包 from sets import set
| Method or Operation | Description |
| len(set) | Returns the number of elements in a given set |
| copy() | Returns a new shallow copy of the set |
| difference(set2) | Returns a new set that contains all elements that are in the calling set, but not in set2 |
| intersection(set2) | Returns a new set that contains all elements that the calling set and set2 have in common |
| issubbset(set2) | Returns a Boolean stating whether all elements in calling set are also in set2 |
| issuperset(set2) | Returns a Boolean stating whether all elements in set2 are contained in calling set |
| symmetric_difference(set2) | Returns a new set containing elements either from the calling set or set2 but not from both (set1 ^ set2) |
| x in set | Tests whether x is contained in the set, returns boolean |
| x not in set |
|
| union(set2) | Returns a new set containing elements that are contained in both the calling set and set2 |
| Method or Operation | Description |
| add(item) | Adds an item to a set if it is not already in the set |
| clear() | Removes all items in a set |
| difference_update(set2) | Returns the set with all elements contained in set2 removed |
| discard(element) | Removes designated element from set if present |
| intersection_update(set2) | Returns the set keeping only those elements that are also in set2 |
| pop() | Return an arbitrary element from the set |
| remove(element) | Remove element from set if present, if not then KeyError is raised |
| symmetric_difference_update(set2) | Replace the calling set with a set containing elements from either the calling set or set2 but not both, and return it |
| update(set2) | Returns set including all elements from set2 |
7. read()和readlines()读出内容的格式是不一样的,如果当前的位置是在文件的末端必须要seek,不然读不出来内容。
8.在string和list中,不用创建迭代器,也可以使用for进行迭代。如果将一个不可改变的对象赋给另外一个变量,例如string和integer .那这个变量是这个string的copy,改变这个变量的值不会改变string. 如果将一个可改变的对象赋给另外一个变量,例如list.那这个变量是这个List的引用,也就是同一个东西,改变这个变量的值会同时改变list。如果要得到一个list(a)的copy,那么要import copy,同时使用b=copy.copy(a).但这样也仅仅是一个浅copy。也就是说,不同的对象,但是同一个引用,虽然b is a 为false。但是如果改变b的值,a也会同样的改变。如果非要使用deepcopy,那么就要import copy,然后b=copy.deepcopy(a),这样改变了b的值之后,a的值就不会改变了。
jython语言学习笔记的更多相关文章
- HTML语言学习笔记(会更新)
# HTML语言学习笔记(会更新) 一个html文件是由一系列的元素和标签组成的. 标签: 1.<html></html> 表示该文件为超文本标记语言(HTML)编写的.成对出 ...
- 2017-04-21周C语言学习笔记
C语言学习笔记:... --------------------------------- C语言学习笔记:学习程度的高低取决于.自学能力的高低.有的时候生活就是这样的.聪明的人有时候需要.用笨的方法 ...
- 2017-05-4-C语言学习笔记
C语言学习笔记... ------------------------------------ Hello C语言:什么是程序:程序是指:完成某件事的既定方式和过程.计算机中的程序是指:为了让计算机执 ...
- GO语言学习笔记(一)
GO语言学习笔记 1.数组切片slice:可动态增长的数组 2.错误处理流程关键字:defer panic recover 3.变量的初始化:以下效果一样 `var a int = 10` `var ...
- Haskell语言学习笔记(88)语言扩展(1)
ExistentialQuantification {-# LANGUAGE ExistentialQuantification #-} 存在类型专用的语言扩展 Haskell语言学习笔记(73)Ex ...
- Go语言学习笔记十三: Map集合
Go语言学习笔记十三: Map集合 Map在每种语言中基本都有,Java中是属于集合类Map,其包括HashMap, TreeMap等.而Python语言直接就属于一种类型,写法上比Java还简单. ...
- Go语言学习笔记十二: 范围(Range)
Go语言学习笔记十二: 范围(Range) rang这个关键字主要用来遍历数组,切片,通道或Map.在数组和切片中返回索引值,在Map中返回key. 这个特别像python的方式.不过写法上比较怪异使 ...
- Go语言学习笔记十一: 切片(slice)
Go语言学习笔记十一: 切片(slice) 切片这个概念我是从python语言中学到的,当时感觉这个东西真的比较好用.不像java语言写起来就比较繁琐.不过我觉得未来java语法也会支持的. 定义切片 ...
- Go语言学习笔记十: 结构体
Go语言学习笔记十: 结构体 Go语言的结构体语法和C语言类似.而结构体这个概念就类似高级语言Java中的类. 结构体定义 结构体有两个关键字type和struct,中间夹着一个结构体名称.大括号里面 ...
随机推荐
- JBOSS /invoker/JMXInvokerServlet 利用工具 .
链接: http://pan.baidu.com/s/1F8bMI 密码: 1h2r 工具使用说明 1. 查看系统名称 java -jar jboss_exploit_fat.jar -i http: ...
- android 检查网络连接状态实现步骤
获取网络信息需要在AndroidManifest.xml文件中加入相应的权限. <uses-permission android:name="android.permission.AC ...
- android点滴之ViewTreeObserver
一类的基本概念 这是一个注册监听视图树的观察者(observer),在视图树种全局事件改变时得到通知.这个全局事件不仅还包括整个树的布局,从绘画过程开始,触摸模式的改变等.最常见的用途时通过监听获知什 ...
- 1、JavaScript入门篇
一.你知道,为什么JavaScript非常值得我们学习吗? 1. 所有主流浏览器都支持JavaScript. 2. 目前,全世界大部分网页都使用JavaScript. 3. 它可以让网页呈现各种动态效 ...
- SVG 参考手册
1. SVG元素模块 Animation.Module animate animateColor animateTransform animateMotion set mpath 剪裁模块 clipP ...
- dojo使用疑难杂症集锦
最近在用dojo做项目, 把使用过程中遇到的一些问题记录下来, 方便以后查阅, 因为问题不断, 所以持续更新中.......... 嵌套 TabContainer 时会出现样式问题: tab控制样式问 ...
- openId 列表
http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html 根据OpenID列表群发[订阅号不可用,服务号认证后可用] ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
- C#: 自定义控件
(一)复合控件 http://wenku.baidu.com/link?url=y4BdtX3mOer4Hdin019jJpXJLi-2_ehmEo7i08cxEp1OR_3gb5CqaHrnNEB2 ...
- BroadCast Receive 生命周期
BroadCastReceiver 简介 BroadCastReceiver 源码位于: framework/base/core/java/android.content.BroadcastRecei ...