我的数组中有12条记录,但我只想打印出一个特定的值,我尝试了以下内容:
import pytest
import tornado
from tornado.testing import AsyncTestCase
from tornado.httpclient import AsyncHTTPClient
from tornado.web import Application, RequestHandler
import urllib.parse
class TestRESTAuthHandler(AsyncTestCase):
@tornado.testing.gen_test
def test_http_fetch_login(self):
data = urllib.parse.urlencode(dict(username='admin', password='123456'))
client = AsyncHTTPClient(self.io_loop)
response = yield client.fetch("http://localhost:8080//#/login", method="POST", body=data)
# Test contents of response
self.assertIn("Automation web console", response.body)
但这是打印出第一个字符而不是第一个完整的值。
例如。如果我的记录是:星期一,星期二,星期三等我想要星期一,但它只是给我'M'。
有人能指出我正确的方向吗?
答案 0 :(得分:3)
$percentSKU['PercentageSales']
之类的声音本身就是string
。在字符串上使用[0]
可以获得第一个字符,这正是发生的事情。只是不要指定任何东西来获取整个字符串:
echo $percentSKU['PercentageSales'];