我有一个从套接字读取的无限循环。每分钟,我将写入位置更改为下一分钟。
问题是流中的最后一行在中间被截断并放入下一个文件。我有办法告诉它只在换行符处停下来,而不是在中间吗?
$path = 'bin_images/file_name.jpeg';
$image = str_replace('data:image/png;base64,', '', $request->image);
$image = str_replace(' ', '+', $image);
Storage::put($path, base64_decode($image));
答案 0 :(得分:1)
如果只有一个插槽,则不需要CREATE FUNCTION ufn_GetBusinessRuleValue
(
-- Add the parameters for the function here
@FieldName VARCHAR(MAX) NOT NULL
)
RETURNS TABLE
AS
RETURN
(
-- Add the SELECT statement with parameter references here
SELECT
FieldValue
FROM
[BVI].[dbo].[BusinessRules] br
WHERE
br.ClientID = DB_NAME()
AND DATEDIFF(DAY, GETDATE(), ActiveDate) <= 0
AND (DATEDIFF(DAY, GETDATE(), InactiveDate) >= 0 OR InactiveDate IS NULL)
AND br.FieldName = 'ufn_GetBVIEmpType.Configuration'
)
。使用select
并读取以下行:
makefile
答案 1 :(得分:0)
我会
例如使用Collection
:
str.rpartition
像这样:
>>> left_part,_,remaining_line = "a\nb\nc".rpartition("\n")
>>> left_part
'a\nb'
>>> remaining_line
'c'
请注意,如果需要,您应该对最后一个remaining_line = ""
while ok:
filename1 = datetime.datetime.now().strftime("FILE.0000.%Y.%m.%d.%H.%M.txt")
path="/tmp/" + filename1
with open(path,"a") as f:
if remaining_line:
file1.write(remaining_line)
for s in ready_to_read:
line = s.recv(1024)
if line:
left_part,_,remaining_line = line.rpartition("\n");
file1.write(left_part)
file1.write("\n")
else:
ok = False
(当remaining_line
为ok
时)进行操作。