- list to string
- array to string
1 PHP[ | ]


PHP
Copy
$arr = [10,"test",10.5];
$str = print_r( $arr, true );
echo gettype($str) . PHP_EOL;
print_r( $str );
# string
# Array
# (
# [0] => 10
# [1] => test
# [2] => 10.5
# )
PHP
Copy
$arr = [10,"test",10.5];
$str = var_export( $arr, true );
echo gettype($str) . PHP_EOL;
print_r( $str );
# string
# array (
# 0 => 10,
# 1 => 'test',
# 2 => 10.5,
# )
2 Python[ | ]
- Python 2
Python
Copy
mylist = [10,"test",10.5]
mystr = str(mylist)
print( type(mystr) )
print( mystr )
# <type 'str'>
# [10, 'test', 10.5]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.