使用getparameter()或者getparametervalues()方法從表單中得到的資料,可能是字串型別或者字串陣列,在實際應用中常常需要得到其他型別
轉換結果型別
轉換方法
byte
byte.parsebyte(string s) / byte.valueof(string s)
boolean
boolean.parsebyte(string s) / boolean.valueof(string s)
short
short.parsebyte(string s) / short.valueof(string s)
stringstring.valueof(type t)其中:type可以是float,int,double,object等型別
object
new string(string s)
注意:getattribute()返回的是object型別
將object型別轉換為其他基本型別:如:object物件名.intvalue();轉為int
其他型別轉換為字串
1。短整型 int itoa i,temp,10 將i轉換為字串放入temp中,最後乙個數字表示十進位制 itoa i,temp,2 按二進位制方式轉換 2。長整型 long ltoa l,temp,10 3。浮點數 float,double 用fcvt可以完成轉換,這是msdn中的例子 int d...
python 陣列轉換為string
先看下join函式 語法為 str.join sequence sequence 要連線的元素序列例項一 連線字串 str1 seq a b c print str1.join seq 例項二 連線陣列 陣列元素為字串 str2 seq2 a b c print str2.join seq2 例項三...
string型別轉換為char
標準庫string類提供了3個成員函式來從乙個string得到c型別的字元陣列,c str data copy p,n 1.c str 是borland封裝的string類中的乙個函式,它返回當前字串的首位址。換種說法,c str 函式返回乙個指向正規c字串的指標常量,內容與本 string串相同。...